package com.example.lt.text;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @Author 小涛Tao
 * @Date: 2024/08/12/12:07
 * version 1.0 注释：
 **/
public class WeightRandom {

    public double weightRandom() {
        final double random = Math.random();
        final double v = random * 9 + 1;
        final double v1 = (int)(v * 100000);
        //int i = (int) ((Math.random() * 9 + 1) * 100000);
        System.out.println(v1);
        return v1 / 1000000.0;
    }

    public String labelTest(List<String> str1, List<String> str2) {

        Set<String> setLabels = new HashSet<>();
        setLabels.addAll(str1);
        setLabels.addAll(str2);
        StringBuilder sb = new StringBuilder();
        for (String label : setLabels) {
            sb.append(label + ",");
        }
        sb.deleteCharAt(sb.lastIndexOf(","));

        return sb.toString();
    }

}
